package main

import "fmt"

func main() {
	//map声明
	var mapLit map[string]int
	var mapVal map[string]int

	mapLit = map[string]int{"a": 1, "b": 2, "c": 3}
	mapVal = mapLit
	//mapVal 是 mapList 的引用
	mapVal["c"] = 4

	fmt.Printf("Map literal at \"a\" is: %d\n", mapLit["a"])
	fmt.Printf("Map literal at \"b\" is: %d\n", mapVal["b"])
	fmt.Printf("Map literal at \"c\" is: %d\n", mapLit["c"])

	//循环遍历
	scene := make(map[string]int, 10)
	scene["dog"] = 11
	scene["cat"] = 20
	scene["pig"] = 30

	for k, v := range scene {
		fmt.Printf("name:%s,num:%d\n", k, v)
	}
	fmt.Println()
	//删除
	delete(scene, "cat")
	for k, v := range scene {
		fmt.Printf("name:%s,num:%d\n", k, v)
	}

}
